package com.cqupt.utils;


import cn.hutool.system.UserInfo;
import com.cqupt.model.pojo.SysUser;

public class AuthContextUtil {
    private AuthContextUtil() {
    }

    // 创建 ThreadLocal 对象
    private static final ThreadLocal<SysUser> threadlocal = new ThreadLocal<>();

    // 添加数据
    public static void set(SysUser sysUser) {
        threadlocal.set(sysUser);
    }

    // 获取数据
    public static SysUser get() {
        return threadlocal.get();
    }

    // 删除数据
    public static void remove() {
        threadlocal.remove();
    }


    private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>() ;


    // 定义存储数据的静态方法
    public static void setUserInfo(UserInfo userInfo) {
        userInfoThreadLocal.set(userInfo);
    }

    // 定义获取数据的方法
    public static UserInfo getUserInfo() {
        return userInfoThreadLocal.get() ;
    }

    // 删除数据的方法
    public static void removeUserInfo() {
        userInfoThreadLocal.remove();
    }

}
